//
//  CellForSPSound.m
//  StayAwhile
//
//  Created by dllo on 16/1/28.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CellForSPSound.h"
#import "TXPSPSound.h"
@interface CellForSPSound ()
@property(nonatomic,strong)UILabel *nameLaber;
@property(nonatomic,strong)UILabel *titleLaber;
@property(nonatomic,strong)UIImageView *coverimgView;
@property(nonatomic,strong)UILabel *likeLabel;
@property(nonatomic,strong)UILabel *byLaber;
@property(nonatomic,strong)UIImageView *playImageView;
@end

@implementation CellForSPSound

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubview];
    }
    return self;
}
-(void)createSubview{
    self.nameLaber =[[UILabel alloc] initWithFrame:CGRectMake(15, 10, WIDTH - 20, 20)];
    self.nameLaber.font = [UIFont systemFontOfSize:13];
    self.nameLaber.textColor = [UIColor grayColor];
    self.coverimgView =[[UIImageView alloc] initWithFrame:CGRectMake(30, 35, WIDTH -60, 150)];
    self.playImageView =[[UIImageView alloc] initWithFrame:CGRectMake(WIDTH/2 -15,170,30, 30)];
    self.playImageView.image =[UIImage imageNamed:@"iconfont-bofang-5"];
    
    self.titleLaber =[[UILabel alloc]initWithFrame:CGRectMake(15, 210, WIDTH -30, 20)];
    self.titleLaber.textAlignment = NSTextAlignmentCenter;
    self.byLaber =[[UILabel alloc] initWithFrame:CGRectMake(0, 240, WIDTH, 20)];
    self.byLaber.font = [UIFont systemFontOfSize:13];
    self.byLaber.textColor = [UIColor grayColor];
    self.byLaber.textAlignment = NSTextAlignmentCenter;
      self.likeLabel =[[UILabel alloc] initWithFrame:CGRectMake(20, 260, WIDTH - 40, 20)];
    self.likeLabel.textAlignment =NSTextAlignmentRight;
    self.likeLabel.font = [UIFont systemFontOfSize:13];
    self.likeLabel.textColor = [UIColor grayColor];
    
    [self.contentView addSubview:self.playImageView];
    [self.contentView addSubview:self.nameLaber];
    [self.contentView addSubview:self.coverimgView];
    [self.contentView addSubview:self.titleLaber];
    [self.contentView addSubview:self.byLaber];
    [self.contentView addSubview:self.likeLabel];
}


-(void)setBaseModel:(TXPSPBaseModel *)baseModel{
    [super setBaseModel:baseModel];
    TXPSPSound *sound =(TXPSPSound *)baseModel;
    NSString *str =[sound.name stringByAppendingString:@"·"];
    NSString *strone =[str stringByAppendingString:sound.enname];
    self.nameLaber.text = strone;
    self.titleLaber.text = sound.title;
    NSString *like =[NSString stringWithFormat:@"%ld",sound.like];
    self.likeLabel.text = like;
    [self.coverimgView sd_setImageWithURL: [NSURL URLWithString:sound.coverimg]placeholderImage:nil];
    self.byLaber.text =[@"by:" stringByAppendingString:[sound.userinfo objectForKey:@"uname"]];
}

@end
